class SdweatherspiderPipeline:
    def process_item(self, item, spider):
        with open('weather.txt', 'a', encoding='utf-8') as f:
            # 同时显示城市名称和城市编码（假设item中新增了'city_code'字段）
            f.write(f'=== {item["city"]} (城市编码: {item["city_code"]}) 天气 ===\n')
            f.write(f'{item["weather"]}\n\n')
        return item
